-- markdown预览

vim.cmd([[
    function OpenMarkdownPreview (url)
      execute "silent ! firefox " . a:url 
      
    endfunction
    let g:mkdp_browserfunc = 'OpenMarkdownPreview'

]])
return {
  {
    "iamcco/markdown-preview.nvim",
    cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
    event = "BufRead",
    enabled = false,
    build = "cd app && yarn install",
    init = function()
      vim.g.mkdp_filetypes = { "markdown" }
    end,
    ft = { "markdown" },

    --不知道为什么不执行，使用指令以加载' call mkdp#util#install() '
  },
  {
    -- 需要安装deno：
    -- curl -fsSL https://deno.land/install.sh | sh 或 npm install -g deno
    -- webview 无法打开:
    -- sudo apt install libwebkit2gtk-4.0-dev
    -- https://webkitgtk.org/
    -- 安装MagickWand:sudo apt install libmagickwand-dev libmagickcore-dev libwandio1-dev

    "toppair/peek.nvim",
    event = { "VeryLazy" },
    enabled = true,
    build = "deno task --quiet build:fast",
    -- keys = {
    -- {
    -- "<F5>",
    -- function()
    -- local peek = require("peek")
    -- if peek.is_open() then
    -- peek.close()
    -- else
    -- peek.open()
    -- end
    -- end,
    -- desc = "Peek (Markdown Preview)",
    -- },
    -- },
    config = function()
      require("peek").setup({

        theme = "dark", -- 'dark' or 'light'

        app = "chromium",
        -- app = { "firefox-esr", "-private-window" },
        -- app = "webview", -- 'webview', 'browser', string or a table of strings
        -- app = { "chromium", "--app=http://localhost:9000/?theme=dark", "--incognito" },
        -- explained below

        -- filetype = { "markdown" }, -- list of filetypes to recognize as markdown
      })
      vim.api.nvim_create_user_command("PeekOpen", require("peek").open, {})
      vim.api.nvim_create_user_command("PeekClose", require("peek").close, {})
    end,
  },
}
